package com.mask.im.business.controller;

import com.mask.im.business.model.entity.Notify;
import com.mask.im.business.model.dto.MailDTO;
import com.mask.im.business.model.dto.NotifyUserDTO;
import com.mask.im.business.model.vo.ConditionVO;
import com.mask.im.business.common.model.PageResult;
import com.mask.im.business.common.model.RestResponse;
import com.mask.im.business.service.NotifyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "通知模块")
@RestController
public class NotifyController {

    @Autowired
    private NotifyService notifyService;


    @ApiOperation("后台获取通知列表")
    @GetMapping("/admin/notifyList")
    public PageResult<Notify> getAdminNotify(ConditionVO conditionVO) {
        return notifyService.getAdminNotify(conditionVO);
    }


    @ApiOperation("删除通知记录")
    @DeleteMapping("/admin/notify")
    public RestResponse<String> deleteNotify(@Param("id") Integer id) {
        return notifyService.deleteNotify(id);
    }


    @ApiOperation("获取通知内容")
    @GetMapping("/users/notify")
    public RestResponse<List<NotifyUserDTO>> getUserNotify() {
        return notifyService.getUserNotify();
    }


    @ApiOperation("根据Id获取通知")
    @GetMapping("/users/NotifyById/{id}")
    public RestResponse<MailDTO> notifyById(@PathVariable Integer id) {
        return notifyService.notifyById(id);
    }


    @ApiOperation("我已阅读")
    @PutMapping("/users/notify/read/{id}")
    public RestResponse<String> readNotify(@PathVariable Integer id) {
        return notifyService.readNotify(id);
    }
}

